<?php

namespace App\Http\Resources;

use App\Helpers\BaseResource;
use App\Helpers\FileTool;

class LiveroomBanner extends BaseResource
{

    public function toArray($request)
    {
        if ($this->rs_type=='vux'){
            return $this->filterFields([
                'url'=>'/r/'.$this->link_type.'?id='.hashid_encode($this->link_id),
                'title' => $this->link_type == 'channel' ? $this->channel->name : $this->lecture->name,
                'img' => FileTool::thumb($this->cover,'imageView2/1/w/840/h/480/q/100'),
            ]);
        }


        return $this->filterFields([
            'id' => hashid_encode($this->id),
            'cover' => $this->cover,
            'cover_url' => FileTool::thumb($this->cover),
            'priority' => $this->priority,
            'link_type' => $this->link_type,
            'link_id' => hashid_encode($this->link_id),
            'link_name' => $this->link_type == 'channel' ? $this->channel->name : $this->lecture->name
        ]);
    }
}
